import { CancellationInfo, WorkflowData, ApiResponse } from './types';

// 模拟API响应数据
const mockCancellationInfo: CancellationInfo = {
  projectId: 'T25AC311',
  projectName: '一些特性B',
  approvalOpinion: '同意',
  changeType: '技术原因',
  changeReason: '技术原因',
  technicalUnitImpact: '',
  cancellationReason: '12',
  attachments: []
};

// 模拟工作流数据
const mockWorkflowData: WorkflowData = {
  nodes: [
    {
      name: '开始',
      status: 'completed'
    },
    {
      name: '发起流程',
      processor: '谢汶沁/80231866',
      processTime: '2025-03-31 15:55:06',
      result: '同意',
      status: 'completed'
    },
    {
      name: '室经理审批',
      processor: '谢汶沁/80231866',
      processTime: '2025-03-31 15:55:38',
      result: '同意',
      status: 'completed'
    },
    {
      name: '开发团队主管与项目管理员审批',
      processor: '杨洋/80273863',
      processTime: '2025-03-31 15:56:23',
      result: '同意',
      status: 'completed'
    },
    {
      name: '结束',
      status: 'completed'
    }
  ],
  currentNode: 4
};

/**
 * 获取项目取消数据
 */
export const fetchCancellationData = async (): Promise<ApiResponse<{
  cancellationInfo: CancellationInfo;
  workflow: WorkflowData;
}>> => {
  // 模拟API请求延迟
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        success: true,
        data: {
          cancellationInfo: mockCancellationInfo,
          workflow: mockWorkflowData
        }
      });
    }, 500);
  });
};

/**
 * 保存项目取消数据
 * @param cancellationInfo 项目取消信息
 */
export const saveCancellationData = async (
  cancellationInfo: CancellationInfo
): Promise<ApiResponse> => {
  // 模拟API请求延迟
  return new Promise((resolve) => {
    setTimeout(() => {
      console.log('保存项目取消数据:', cancellationInfo);
      resolve({
        success: true,
        message: '保存成功'
      });
    }, 800);
  });
}; 